package com.jobpass.utils;


import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;
import org.springframework.stereotype.Component;

public class Md5Utils {

    public String setMD5ForPassword(String salt, String password){
        //加密方式
        String hashAlgorithmName = "MD5";
        //盐：为了即使相同的密码不同的盐加密后的结果也不同
        ByteSource byteSalt = ByteSource.Util.bytes(salt);
        //密码
        Object source = password;
        //加密次数
        int hashIterations = 1024;
        SimpleHash result = new SimpleHash(hashAlgorithmName, source, byteSalt, hashIterations);
        System.out.println(result.toString());
        return result.toString();
    }

    public static void main(String[] args) {
        Md5Utils md5Utils = new Md5Utils();
        md5Utils.setMD5ForPassword("123456","123456");

    }
}
